﻿
@{
    ViewBag.Title = "EditNews";
    Layout = "~/Views/Shared/Admin/_LayoutAdmin.cshtml";
}
@using AIKE_Model;
<link href="~/Lib/Admin/css/EditNews.css" rel="stylesheet" />
<link href="~/Lib/Admin/css/edit/demo.css" rel="stylesheet" />
<link href="~/Lib/Admin/css/edit/bootstrap-markdown.min.css" rel="stylesheet" />

<div class="panel panel-default">
    <div class="panel-heading">发布资讯</div>
    <div class="row">
        <div class="col-md-7">
            <input type="text" class="title" id="title" placeholder="标题">
            <br /><br /><br />

            <div class="demo">
                <div class="container">
                    <textarea id="editor-zh" name="content" rows="8">@ViewData["editNew"]</textarea>
                </div>
            </div>

            @*<script src="js/jquery-1.11.0.min.js" type="text/javascript"></script>
        <script type="text/javascript" src="js/bootstrap.min.js"></script>
        <script type="text/javascript" src="js/bootstrap-markdown.js"></script>
        <script type="text/javascript" src="locale/bootstrap-markdown.zh.js"></script>*@



            <script src="~/Common/jquery-2.1.1.js"></script>
            <script src="~/Lib/Admin/js/edit/bootstrap.min.js"></script>
            <script src="~/Lib/Admin/js/edit/bootstrap-markdown.js"></script>
            <script src="~/Lib/Admin/js/edit/bootstrap-markdown.zh.js"></script>

            <script type="text/javascript">
                $(function () {
                    $("#editor-zh").markdown({ language: 'zh' })
                })
            </script>
        </div>
        <div class="col-md-3">

            <div class="panel panel-default">

                <div class="panel-heading">设置项</div>
                <table class="table">
                    <tr>
                        <td>
                            <label>文章封面：</label>
                            <input type="file" name="file" id="Msg_File" />
                            <input type="text" id="msg_txt" placeholder="资讯封面" />
                        </td>
                    </tr>

                    <tr>
                        <td>
                            <label>资讯分类：</label>
                            <select id="type">
                                @foreach (string s in (List<string>)ViewData["MsgType"])
                                {
                                    <option>@s</option>
                                }
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label>转载地址：</label>
                            <input type="text" placeholder="" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <button class="FMsg btn btn-primary">发布</button>&nbsp;&nbsp;
                            <button class="btn btn-default">保存草稿</button>
                        </td>

                    </tr>

                </table>
            </div>

        </div>
    </div>
</div>
<script src="~/Common/ajaxfileupload.js"></script>
<script>
    $(function () {
        $("#Msg_File").change(function () {
             $.ajaxFileUpload({
                    url: '@Url.Action("FileUpload", "Admin")',
                    datatype: "json",
                    type:"post",
                    secureuri: false,
                    fileElementId: 'Msg_File',//文件input标签id
                    data: {},
                 success: function (data) {
                     debugger
                     $("#msg_txt").val(data.responseText);
                    },
            error: function (data){
                debugger
                $("#msg_txt").val(data.responseText)
            }
        });

        });
    });
</script>

<script>
    $(function () {
        $(".FMsg").click(function () {
            alert($("#type option:selected").val())
            $.ajax({
                url: "../Admin/FMsg",
                data: { "title": $("#title").val(), "txt": $("#editor-zh").val(), "type": $("#type option:selected").val(), "msg_txt": $("#msg_txt").val() },
                success: function () {
                
                },
                error: function () {
                
}

            });
        
        });

    });
</script>


